package com.shujia.scala

import com.alibaba.fastjson.{JSON, JSONArray, JSONObject}

object Demo9Json {
  def main(args: Array[String]): Unit = {
    val str = "{\"id\":\"001\",\"name\":\"张三\",\"item\":[1,2,3,4]}"

    //解析json数据
    val nObject: JSONObject = JSON.parseObject(str)

    //使用key获取value
    //需要明确类型
    val id: String = nObject.getString("id")

    val name: String = nObject.getString("name")

    val item: JSONArray = nObject.getJSONArray("item")
    println(id)
    println(name)
    println(item)


  }
}
